#ifndef DARKFOODCARD_H
#define DARKFOODCARD_H

#include <QWidget>
#include <QLabel>
#include <QPushButton>
#include <QLabel> // Changed from QSpinBox
#include <QVBoxLayout> // Or other layout
#include <QHBoxLayout> // Added for quantity controls

// Forward declaration if needed
class QPainter;

// 商品卡片控件
class DarkFoodCard : public QWidget {
    Q_OBJECT
public:
    explicit DarkFoodCard(QWidget* parent = nullptr);

    // Method to set the details from a Drink struct (or individual fields)
    void setDrinkDetails(const QString& name, const QString& category, float price, int drinkId);

    QSize sizeHint() const override { return QSize(180, 250); } // Adjusted size hint

signals:
    // Signal emitted when the add button is clicked
    void addToCartClicked(int drinkId, int quantity);

protected:
     // Keep paintEvent if you still want custom drawing (e.g., background, image placeholder)
     void paintEvent(QPaintEvent* event) override;

private slots:
    void onAddToCartClicked(); // Slot connected to the button
    void onIncreaseQuantity(); // Slot for '+' button
    void onDecreaseQuantity(); // Slot for '-' button

private:
    void setupUi(); // Helper to create UI elements

    QLabel* nameLabel;
    QLabel* priceLabel;
    // QLabel* categoryLabel; // Optional: if you want to display category
    // QLabel* imageLabel; // Placeholder for image
    QPushButton* decreaseButton;
    QLabel* quantityLabel;
    QPushButton* increaseButton;
    QPushButton* addToCartButton;

    int m_quantity = 1; // Internal quantity state
    int m_drinkId = -1; // Store the ID of the drink displayed
    QString m_drinkName; // Store name for potential use in signals/tooltips
    float m_drinkPrice; // Store price if needed

    // Remove animation related members if animation is removed
    // QTimer m_timer;
    // QPropertyAnimation* m_anim = nullptr;
    // float m_animValue = 0.0f;
    // bool m_animRunning = false;
    // void drawCoffee(QPainter& p); // etc.
};

#endif // DARKFOODCARD_H